home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9573 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  40 lines

  1. Newsgroups: comp.lang.c
  2. Path: in2.uu.net!world!klanza
  3. From: klanza@world.std.com (Kurt J Lanza)
  4. Subject: Re: confusion between putchar and printf
  5. Message-ID: <Do4GwL.Kv4@world.std.com>
  6. Organization: The World Public Access UNIX, Brookline, MA
  7. References: <4i1v2n$30o@news.azstarnet.com>
  8. Date: Mon, 11 Mar 1996 21:26:45 GMT
  9.  
  10. Howard Salmon <captarm@azstarnet.com> writes:
  11.  
  12. >K & R (section 1.5) states that "putchar(c) prints the contents of the 
  13. >integer variable c as a character, usually on the screen".
  14.  
  15. >Here's a small program that I wrote testing putchar.  Why doesn't it 
  16. >compile?
  17.  
  18. >#include <stdio.h>
  19. ># define A "hello world!"
  20.  
  21. >main()
  22. >{
  23. >    int c;
  24. >    c =  A;            (1)
  25. >    putchar(A);        (2)
  26. >}
  27.  
  28. >Thanks, 
  29. >        Howard Salmon (captarm@azstarnet.com)
  30.  
  31. What did the compiler say? Something about invalid type, I
  32. wouls suspect. You have defined A as a character pointer.
  33. (1) You can't assign a character pointer to an integer.
  34. (2) Putchar() prints a single integer as a single character
  35. -- this won't do what you want. It looks like you badly need
  36. an intro to C programming. Hope this helps.
  37. -- 
  38. --
  39. Kurt J. Lanza <kjl@infor.com>
  40.